package com.jack.config.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.io.Serializable;
import java.time.LocalDateTime;
//注解在类上，为类提供一个无参的构造方法
@NoArgsConstructor
//使用后添加一个构造函数，该构造函数含有所有已声明字段属性参数
@AllArgsConstructor
@Document(indexName = "sys_user", shards = 1,replicas = 1)
@Data
public class User implements Serializable {
    @Id
    @Field(type = FieldType.Long)
    private long id;
    //采用分词
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String name;

    @Field(type = FieldType.Integer)
    private int age;

    @Field(type = FieldType.Date,
            format = DateFormat.custom,
            pattern = "uuuu-MM-dd HH:mm:ss")
//    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime createTime;

    private String sex;
    public User(String name, Integer age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }
}
